package com.atguigu.gmall.mapper;

import com.atguigu.gmall.beans.KeywordStats;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author: tiancy
 * Date: 2021/12/11
 * Desc: 关键词统计接口
 */
public interface KeywordStatsMapper {

    @Select("select keyword,   " +
        "  sum(keyword_stats_0609.ct *  " +
        "   multiIf( " +
        "    source='SEARCH',10, " +
        "    source='ORDER',5, " +
        "    source='CART',2, " +
        "    source='CLICK',1,0 " +
        "   ) " +
        "  ) ct   " +
        " from keyword_stats_0609 where toYYYYMMDD(stt)= #{date} " +
        " group by keyword order by ct desc limit #{limit}")
    List<KeywordStats> selectKeyword(@Param("date") Integer date, @Param("limit") Integer limit);
}